package com.springcloud.auth.controller;

import com.entity.ResponseResultSet;
import com.uitl.JwtUitl;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author
 * @create 2020-11-11 23:02
 */
@RestController
public class LoginController {

    @RequestMapping("/login")
    public ResponseResultSet login(String UserName,String PassWord){
        if(UserName.equals("ljw") && PassWord.equals("123456")){
            //用户登录成功，服务器将生成好的token返回给客户端
            String token = JwtUitl.create(UserName);
            System.out.println(UserName);
            System.out.println(PassWord);
            System.out.println(token);
            return new ResponseResultSet(200,"login success",token);
        }else{
            return new ResponseResultSet(401,"请先登录后在访问",null);
        }
    }

}
